package com.wangzhixuan.service.impl;

import java.util.List;
import java.util.Map;

import com.wangzhixuan.commons.utils.PageInfo;
import com.wangzhixuan.model.Skydrive;
import com.wangzhixuan.model.vo.FileFullVo;
import com.wangzhixuan.mapper.SkydriveMapper;
import com.wangzhixuan.service.ISkydriveService;
import com.baomidou.mybatisplus.plugins.Page;

import org.springframework.beans.factory.annotation.Autowired;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhixuan.wang
 * @since 2017-08-22
 */
@Service
public class SkydriveServiceImpl extends ServiceImpl<SkydriveMapper, Skydrive> implements ISkydriveService {
	
	@Autowired
    private SkydriveMapper skydriveMapper;
    
	@Override
    public void selectDataGrid(PageInfo pageInfo,Integer sId,Integer userId,Integer isShare) {
    	Page<Map<String, Object>> page = new Page<Map<String, Object>>(pageInfo.getNowpage(), pageInfo.getSize());
        page.setOrderByField(pageInfo.getSort());
        page.setAsc(pageInfo.getOrder().equalsIgnoreCase("asc"));
        List<Skydrive> list = skydriveMapper.selectSkydrivePage(page, pageInfo.getCondition(),sId,userId,isShare);
        pageInfo.setRows(list);
        pageInfo.setTotal(page.getTotal());
    }

	@Override
	public List<Map<String,Object>> selectFileDetailed(Integer userId, Integer fileId) {
		List<Map<String,Object>> fileDetailed = skydriveMapper.selectFileDetailed(userId, fileId);
		return fileDetailed;
	}

	@Override
	public List<Map<String, Object>> selectHistory(Integer userId) {
		List<Map<String,Object>> history = skydriveMapper.selectHistory(userId);
		return history;
	}

	@Override
	public Map<String, Object> selectDynamic(Integer userId) {
		// TODO Auto-generated method stub
		Map<String, Object> map = skydriveMapper.selectDynamic(userId);
		return map;
	}

	@Override
	public List<Map<String, Object>> dynamicHistory(Integer userId) {
		List<Map<String,Object>> dynamicHistory = skydriveMapper.dynamicHistory(userId);
		return dynamicHistory;
	}

	@Override
	public FileFullVo selectFileFull(Integer Id) {
		FileFullVo fileFull = skydriveMapper.selectFileFull(Id);
		return fileFull;
	}

	@Override
	public List<String> selectFilName(Integer pId) {
		List<String> filName = skydriveMapper.selectFilName(pId);
		return filName;
	}

	@Override
	public Integer selectFileByName(String fileName, Integer pId) {
		Integer fileId = skydriveMapper.selectFileByName(pId, fileName);
		return fileId;
	}

	@Override
	public List<Skydrive> selectSon(Integer fileId) {
		List<Skydrive> skydrive = skydriveMapper.selectSon(fileId);
		return skydrive;
	}

	@Override
	public List<Map<String, Object>> selectGXFileDetailed(Integer userId,
			Integer fileId) {
		List<Map<String, Object>> selectGXFileDetailed = skydriveMapper.selectGXFileDetailed(userId, fileId);
		return selectGXFileDetailed;
	}
}
